/**
 * Copyright (c) 2010-2011 julewa.com.  
 * All rights reserved. 
 * 
 * @author Huang Benhua
 * @date 2011-8-2
 * 
**/
package com.julewa.utils;

import java.util.Collection;
import java.util.Map;

//一些可能会常用的函数
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CollectionUtils {
	
	public static final <T> T firstOf(Collection<T> collection){
		if(collection == null)return null;
		if(collection.isEmpty())return null;
		return collection.iterator().next();
	}
	
	public static final boolean isSameMap(Map map1, Map map2){
        if(map1 == map2)return true;
        if(map1 == null || map2 == null)return false;
        if(map1.size() != map2.size())return false;
        return map1.entrySet().equals(map2.entrySet());
    }
 
	public static final int compare(Comparable v1, Comparable v2){
		if(v1 == v2)return 0;
		if(v1 == null)return -1;
		if(v2 == null)return 1;
		return v1.compareTo(v2);
	}
	
}
